﻿@{
    Layout = "~/Views/Shared/_LayoutMobile.cshtml";
    ViewBag.Title = "重置密码";
}

@section Header{
<script>
    Zepto(function ($) {
        $('#btn-register').click(function () {
            if (!$('#txtUserMobile').val()) {
                $('#txtUserMobile').focus();
                utils.ui.showPopMsg('请录入手机号');
                return false;
            }
            if (!$('#txtPhoneCode').val()) {
                $('#txtPhoneCode').focus();
                utils.ui.showPopMsg('请录入手机验证码');
                return false;
            }
            if (!$('#txtUserPassword').val()) {
                $('#txtUserPassword').focus();
                utils.ui.showPopMsg('请录入新密码');
                return false;
            }
            return true;
        });
        $('.pwd-toggle').click(function () {
            var $prev = $(this).prev();
            if ($(this).hasClass('active')) {
                $(this).removeClass('active');
                $prev.attr('type', 'password');
            } else {
                $(this).addClass('active');
                $prev.attr('type', 'text');
            }
        });
        $('#btn-phone-code').click(function () {
            if (!$('#txtUserMobile').val()) {
                $('#txtUserMobile').focus();
                utils.ui.showPopMsg('请录入手机号');
                return false;
            }

            var $self = $(this), seconds = 60;

            $.post('@Url.Action("MobileCode")', { txtImageCode: $('#txtImageCode').val(), txtUserMobile: $('#txtUserMobile').val() }, function (data) {
                $('#img-vcode').trigger('click');
                if (data && data.success) {
                    repeat();
                } else {
                    utils.ui.showPopMsg(data ? data.message : '未知错误');
                }
            }, 'json');

            return;

            function repeat() {
                var inter = setInterval(function () {
                    if ((--seconds) <= 0) {
                        clearInterval(inter);
                        $self.text('发送验证码');
                        $self.prop('disabled', false);
                        return;
                    }
                    $self.prop('disabled', true);
                    $self.text(seconds + '秒后重发');
                }, 1000);
            }
        });
        $('#img-vcode').click(function () {
            $(this).attr('src', '@Url.Action("vvcodeImg","Auth")?date=' + new Date());
        });
        $('.text-clear').click(function () {
            $(this).prev().val('');
        });
        var msg = '@ViewBag.Msg';
        if (msg) {
            utils.ui.showPopMsg(msg);
        }
    });
</script>
}
    <form action="?action=submit&redirect=@HttpUtility.UrlEncode(Request["redirect"])&state=@Request["state"]" method="post">
        <div class="m-login">
        	<div class="typeName">重置密码</div>
        	<ul>
            	<li>
                	<input type="text" maxlength="16" id="txtUserMobile" name="txtUserMobile" placeholder="输入手机号" value="@ViewBag.txtUserMobile"/>
                    <a href="javascript:;" class="text-clear" tabindex="-1"></a>
                </li>
                <li>
                	<input type="text" maxlength="6" id="txtPhoneCode" name="txtPhoneCode" placeholder="输入手机验证码" />
                    <button type="button" id="btn-phone-code">获取验证码</button>
                </li>
                <li>
                	<input type="password" maxlength="16" id="txtUserPassword" name="txtUserPassword"  placeholder="设置新密码" value="@ViewBag.txtUserPassword" />
                    <a href="javascript:;" class="pwd-toggle"></a>
                </li>
            </ul>
            <div class="submit-btns">
            	<button type="submit" id="btn-register" class="btn-danger"> 重置密码</button>
                <div class="other-link f-cb">
                    <p class="f-fr"><a class="f-c-red" href="@Url.Action("index","register")?redirect=@HttpUtility.UrlEncode(Request["redirect"])&state=@Request["state"]">@Html._T("注册")</a></p>
                </div>
            </div>
        </div>
    </form>